Skip to main content

ReplaceCurrentWord

Replaces the current word or part of the current word with the specified text.

Syntax

expression.ReplaceCurrentWord(sReplace, sPart);

expression - A variable that represents a ApiDocument class.

Parameters

NameRequired/OptionalData typeDefaultDescription
sReplaceRequiredstringThe string to replace the current word with.
sPartRequiredundefined"before""after"

Returns

boolean

Example

This example shows how to replace the current word.

let doc = Api.GetDocument();
let para1 = doc.GetElement(0);
para1.AddText("The quick brown ");
let run = para1.AddText("cat");
para1.AddText(" jumps over the lazy dog");
run.MoveCursorToPos(1);

doc.ReplaceCurrentWord("fox");